feat(schemas): v0.1.0 meta-schemas + CI validation (#123, #124)#199
Merged
Conversation
Closes #123, closes #124. Adds two single-file JSON Schema 2020-12 meta-schemas under schemas/v0.1.0/ — decree-schema.{yaml,json} validates the schema-definition format, decree-config.{yaml,json} validates the tenant-side config format. Both use internal $defs only; YAML is the human-edited source, JSON is generated by scripts/yaml-to-json.py and committed alongside for tooling consumers (schemastore.org, IDE language servers) that prefer JSON. The schema meta-schema covers the full v0.1.0 reserved-key surface including the dependentRequired and validations keys landed in #193 / #192. The 4-branch per-type constraint matrix (numeric / string / json / other) uses allOf [if/then] rather than oneOf — better error messages in ajv and python-jsonschema. unevaluatedProperties: false at every object level (works correctly with allOf composition); patternProperties "^x-" allows vendor extensions everywhere. Departs from the schema-spec brief's original "split files + bundling script" plan: the format is small enough that splitting cost more than it saved. Single-file with internal $defs is more idiomatic and easier to read. schema-spec.md updated to reflect the revised approach. Validation harness: - scripts/validate-meta-schemas.py asserts every checked-in *.decree.schema.yaml and *.decree.config.yaml passes the matching meta-schema, AND every fixture under schemas/v0.1.0/testdata/invalid/ fails (proves the meta-schema actually rejects what it claims to). 17 invalid fixtures cover unknown keys, bad spec_version, bad slug, bad field paths, unknown field types, wrong constraints per type, empty rule/message in validations, bad severity, malformed dependentRequired keys, missing required keys, etc. - make validate-meta-schemas runs the script locally. - New CI job "Meta-schemas check" runs unconditionally (no needs.changes gate) so docs-only PRs still validate. Removes the legacy schemas/schema-yaml.json (single-file pre-v0.1.0 meta-schema, missing the new reserved keys). docs/concepts/schemas-and- fields.md updated to reference the new files. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #123. Closes #124.
Summary
Two single-file JSON Schema 2020-12 meta-schemas under `schemas/v0.1.0/`:
Plus a Python validation harness (`scripts/validate-meta-schemas.py`) wired into CI as a new "Meta-schemas check" job, closing #124. The script asserts every checked-in canonical file passes the matching meta-schema and every fixture under `schemas/v0.1.0/testdata/invalid/` fails (proves the meta-schema actually rejects what it claims to). 17 invalid fixtures cover the full failure surface.
Departure from the schema-spec brief
The brief originally specified split-file YAML sources (OpenAPI-style: `field.yaml`, `constraints.yaml`, `info.yaml`, etc.) bundled to a single JSON artifact. The format proved small enough that splitting cost more than it saved — single-file with internal `$defs` is more idiomatic and easier to read. `schema-spec.md` updated to reflect.
What's covered
The schema meta-schema covers the full v0.1.0 reserved-key surface, including:
dependentRequired:to schema spec v0.1.0 (parser + runtime enforcement) #193 and Reserve top-levelvalidations:key in schema spec v0.1.0 (parser only, no engine) #192)YAML→JSON
`scripts/yaml-to-json.py` is a 30-line Python script that converts the human-edited YAML sources to JSON. Both forms are committed alongside each other so consumers (schemastore.org, IDE language servers, CI validators) can `$ref` the JSON directly without a build step.
Test plan
Out of scope